#include <iostream>
#include <cmath>
#include <math.h>
using namespace std;

#define PI 3.14159

class Point
{
    friend class Line;
protected:
    double x,y;

public:
    Point(){x=0;y=0;}
    Point(double xv,double yv){x=xv;y=yv;}

    double Area(){return 0;}
    void Show()
    {
        cout<<"x="<<x<<"\t"<<"y="<<y<<endl;
    }
};

class Circle:public Point{
    double radius;
public:
    Circle(){x=0;y=0;radius=0;}
    Circle(double xv,double yv,double vv):Point(xv,yv)
    {
        radius=vv;
    }

    Circle(Circle &cir):Point(cir)
    {
        radius=cir.radius;
    }

    Circle& operator=(Circle& cir)
    {
        if (this != &cir) {
        // 首先调用基类的赋值运算符
        Point::operator=(cir);
        
        // 然后处理 Circle 类特有的成员变量
        radius = cir.radius;
    }
        return *this;

    }
    
    double Area()
    {
        return PI*radius*radius;
    }

    void show()
    {
        cout<<"x="<<x<<"\t"<<"y="<<y<<"\t"<<"radius="<<radius<<endl;
    }

    double GetRadius()
    {
        return radius;
    }
};

class Line
{
    Point start,end;
public:
    Line():start(0,0),end(0,0){}
    Line(double xv1,double yv1,double xv2,double yv2):start(xv1,yv1),end(xv2,yv2){}
    
    double Getlength()
    {
        return sqrt((start.x-end.x)*(start.x-end.x)+(start.y-end.y)*(start.y-end.y));
    }

    double Area()
    {
        return 0;
    }

    void Show()
    {
        cout<<"start potin:";
        start.Show();
        cout<<"end point:";
        end.Show();
    }
};

class Sphere : public Circle {
public:
    Sphere() : Circle() {}
    Sphere(double xv, double yv, double vv) : Circle(xv, yv, vv) {}

    double Area() {
        return 4 * PI * GetRadius() * GetRadius();
    }

    double Volume() {
        return (4 * PI * GetRadius() * GetRadius() * GetRadius()) / 3.0;
    }
};

class Cylinder : public Circle {
    double height;
public:
    Cylinder() : Circle() { height = 0; }
    Cylinder(double xv, double yv, double vv, double hv) : Circle(xv, yv, vv) {
        height = hv;
    }

    double BaseArea() {
        return Area();
    }

    double LateralArea() {
        return 2 * PI * GetRadius() * height;
    }

    double TotalArea() {
        return BaseArea() + LateralArea();
    }

    double Volume() {
        return BaseArea() * height;
    }
};


int main(int argc,char **argv)
{
    Point pt(0,0);
    Circle cl1(50,50,10),cl2(cl1),cl3;
    Line ln1(0,0,50,50);

    Sphere sp1(20, 20, 5);
    Cylinder cy1(10, 10, 3, 10);

    cout<<"=================================================="<<endl;
    cout<<"点面积:"<<pt.Area()<<endl;
    pt.Show();
    cout<<"=================================================="<<endl;
    cout<<"cl1圆面积:"<<cl1.Area()<<endl;
    cl1.Show();
    cout<<"=================================================="<<endl;
    cout<<"cl2点面积:"<<cl2.Area()<<endl;
    cl2.Show();
    cout<<"=================================================="<<endl;
    cl3=cl1;
    cout<<"cl2点面积:"<<cl3.Area()<<endl;
    cl3.Show();
    cout<<"=================================================="<<endl;
    cout<<"线面积:"<<ln1.Area()<<"\t"<<"线长度:"<<ln1.Getlength()<<endl;
    ln1.Show();

    cout<<"=================================================="<<endl;
    cout << "球面积: " << sp1.Area() << "\t球体积: " << sp1.Volume() << endl;
    sp1.Show();
    cout << "圆柱面积: " << cy1.Area() << "\t圆柱体积: " << cy1.Volume() << endl;
    cy1.Show();

    cout << "==================================================" << endl;
    cout << "圆柱底面积: " << cy1.BaseArea() << "\t圆柱侧面积: " << cy1.LateralArea() << endl;
    cout << "圆柱全面积: " << cy1.TotalArea() << "\t圆柱体积: " << cy1.Volume() << endl;
    cy1.Show();

    return 0;
}